package ect;

import org.lwjgl.input.Mouse;
import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.geom.Rectangle;
import org.newdawn.slick.state.StateBasedGame;

import states.SlickGame;
import buttons.CircleToggleButton;
import globals.PauseAbstract;

public class GeneralPause extends PauseAbstract{
	String title;
	CircleToggleButton gotoMenu;
	int roomNumber;
	TrueTypeFont fontLarge;
	
	public GeneralPause(String t,int r){
		title=t;	roomNumber=r;
		gotoMenu=new CircleToggleButton(SlickGame.width/2,(int) (SlickGame.height*0.7),50,"Menu",Color.blue,Color.green,Color.blue.darker((float) 1.4));
		if(roomNumber==SlickGame.menu){ gotoMenu.disable=true; }
	}
	
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
		fontLarge=new TrueTypeFont(new java.awt.Font("Times New Roman",0,48), true);
	}

	public void update(StateBasedGame sbg, int delta) {
		gotoMenu.update(Mouse.getX(), SlickGame.height-Mouse.getY(), Mouse.isButtonDown(0), delta);
		
		if(gotoMenu.isClicked()){
			gotoMenu.clicked=false;
			this.pauseState=initialState;
			sbg.enterState(SlickGame.menu);
		}
		
	}
	
	public void draw(Graphics g) {
		g.setColor(gray70);
		g.fill(new Rectangle(0, 0, SlickGame.width, SlickGame.height));
		
		g.setColor(new Color((float)(0.886),(float)(0.886),(float)(0.886)));// silver
		g.setFont(fontLarge);
		if(this.pauseState==initialState){
			int tWidth=g.getFont().getWidth(title);
			g.drawString(title, SlickGame.width/2-tWidth/2, 100);
		}
		else if(this.pauseState==playState){
			int tWidth=g.getFont().getWidth("Game Paused!");
			g.drawString("Game Paused!\n", SlickGame.width/2-tWidth/2, 100);
			tWidth=g.getFont().getWidth(title);
			int tHeight=g.getFont().getHeight(title);
			g.drawString(title, SlickGame.width/2-tWidth/2, 100+tHeight-10);
		}
		g.resetFont();
		
		gotoMenu.draw(g);
		
		
	}
	
}
